home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / showchar.ps < prev    next >
Text File  |  1996-01-10  |  3KB  |  95 lines

  1. %    Copyright (C) 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % showchar.ps
  16. % Show the outline and rasterized forms of a character.
  17.  
  18. /F where { pop } { /F /Times-Roman def } ifelse
  19. /P where { pop } { /P 16 def } ifelse
  20. /Rx where { pop } { /Rx 100 def } ifelse
  21. /Ry where { pop } { /Ry 100 def } ifelse
  22. /Cs where { pop } { /Cs (M) def } ifelse
  23. /Pr where { pop } { /Pr false def } ifelse
  24. /Delay where { pop } { /Delay 0 def } ifelse
  25.  
  26. 0 setgray
  27. (markpath.ps) run
  28. (markhint.ps) run
  29. /mmx [1 0 0 1 0 0] def
  30. /getpath        % - getpath <pathproc>
  31.  { [
  32.     { /moveto cvx } { /lineto cvx } { /curveto cvx } { /closepath cvx }
  33.    pathforall
  34.    ] cvx
  35.  } def
  36. /bitselectfont        % <fontname> <scale> bitselectfont -
  37.  { exch findfont exch scalefont setfont
  38.     % Compute the bounding box in device coordinates.
  39.    gsave [Rx 72 div 0 0 Ry 72 div 0 0] setmatrix
  40.    currentfont /FontMatrix get concat
  41.    currentfont /FontBBox get aload pop
  42.    transform ceiling cvi /ury exch def ceiling cvi /urx exch def
  43.    transform floor cvi /lly exch def floor cvi /llx exch def
  44.    /bbx urx llx sub def /bby ury lly sub def
  45.    grestore
  46.  } def
  47. /bitshow        % <string> bitshow -
  48.  { /S exch def gsave
  49.    /W bbx 8 add 7 or 1 add def
  50.    /H bby 8 add def
  51.    /buf W 8 idiv string def
  52.    /M [Rx 72 div 0 0 Ry -72 div 4 llx sub H 4 sub] def
  53.    M W H <ff 00> makeimagedevice
  54.    /dev exch def
  55.    gsave dev setdevice
  56.    newpath 0 lly idtransform moveto
  57.    0 setgray
  58.    gsave
  59.      /hpath S false charpath getpath def
  60.    grestore
  61.    S show grestore
  62.    20 20 translate
  63.    50000 Rx Ry .max P mul div dup scale
  64.    0.7 setgray
  65.    0 W H true M
  66.     { dup 1 add exch dev exch buf copyscanlines
  67.     } imagemask pop
  68.    0 setlinewidth
  69.    gsave 0.5 1 0.5 setrgbcolor hpath exec mmx markpath grestore
  70.    0 0.5 1 setrgbcolor hpath exec stroke
  71.     % Show the hints for Type 1 fonts also.
  72.    currentfont /FontType get 1 eq
  73.     { gsave 1 0 0 setrgbcolor
  74.       0 lly M idtransform translate
  75.       currentfont /FontMatrix get
  76.       dup Pr markfonthints
  77.       currentfont /Encoding get S 0 get get exch Pr markcharhints
  78.       grestore
  79.     }
  80.    if
  81.  } def
  82. F P bitselectfont
  83. /S1 1 string def
  84. Cs
  85.  { /C exch def
  86.    currentfont /Encoding get C get /.notdef ne
  87.     { save S1 0 C put S1 bitshow
  88.       showpage restore
  89.     } if
  90.  } forall
  91. quit
  92.